Add try_to_rfc3339 and to_iso8601, deprecate to_rfc3339#1331
Open
pitdicker wants to merge 3 commits intochronotope:mainfrom
Open
Add try_to_rfc3339 and to_iso8601, deprecate to_rfc3339#1331pitdicker wants to merge 3 commits intochronotope:mainfrom
try_to_rfc3339 and to_iso8601, deprecate to_rfc3339#1331pitdicker wants to merge 3 commits intochronotope:mainfrom
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1331 +/- ##
==========================================
- Coverage 91.80% 91.80% -0.01%
==========================================
Files 40 40
Lines 18329 18360 +31
==========================================
+ Hits 16827 16855 +28
- Misses 1502 1505 +3 ☔ View full report in Codecov by Sentry. |
e0f505f to
92281d8
Compare
4b7710b to
5b394dd
Compare
5b394dd to
37f8e74
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out from #1144.
RFC 3339 is not defined for dates with a year outside of 0..=9999 (like RFC 2822). ISO 8601 does support it.
DateTime::to_rfc3339was a hybrid method, claiming to format a datetime as both valid RFC 3339 and ISO 8601. It would write invalid RFC 3339 strings if the year is out of range, which could not be parsed byDateTime::parse_from_rfc3339.I propose to deprecate
to_rfc3339, and replace it with two methods:try_to_rfc3339andto_iso8601.I did not make
to_rfc3339panic on out-of-range dates liketo_rfc2822, to not break existing uses.It is deprecated with the message: "Produces invalid data on years outside of the range 0..=9999. Use
try_to_rfc3339()orto_iso8601instead."For
DateTime::to_rfc3339_optsand theRFC3339formatting item (used for"%+") I only made some documentation adjustments that they format the value an ISO 8601 representation when the year is out of range.